package com.adingxiong.cft.template;

import lombok.Builder;
import lombok.Data;
import net.sf.jxls.transformer.XLSTransformer;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName ExcelExport
 * @Description TODO
 * @Author xiongchao
 * @Date 2021/5/11 10:23
 **/
public class ExcelExport {

    public static void main(String[] args) {
        String path = "C:\\Users\\Administrator\\Desktop\\test_template.xlsx";


        Map<String,Object> msg = new HashMap<>();
        msg.put("code","标题");
        msg.put("name","旺达");
        msg.put("tel","4211256");
        msg.put("phone","15071384121");
        msg.put("idnum","18");
        msg.put("address","关东街道佳园路路");


        try {
            File tmp = File.createTempFile("模版导出文件" , ".xlsx");
            XLSTransformer transformer = new XLSTransformer();
            transformer.transformXLS(path,msg,tmp.getAbsolutePath());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }





    @Data
    @Builder
    public static class Info {
        String name ;

        String code;

        Integer age;

        String address;

        String tel;

        String phone;
    }
}
